package com.commodity.Service.commodityServiceImp;

import com.commodity.Dao.CommodityDao;
import com.commodity.Dao.commodityDaoImp.CommodityDaoImp;
import com.commodity.Service.CommodityService;
import com.commodity.entity.Commodity;
import com.commodity.entity.CommoditySearchBean;
import com.commodity.utils.BeanFactory;
import com.commodity.utils.PaginateInfo;

import java.util.List;

public class CommodityServiceImp implements CommodityService {
    private final CommodityDao commodityDao = BeanFactory.getInstance(CommodityDaoImp.class);

    @Override
    public List<Commodity> findAll(CommoditySearchBean csb, PaginateInfo pi) {
        return commodityDao.findAll(csb, pi);
    }

    @Override
    public boolean save(Commodity commodity) {
        return commodityDao.save(commodity) > 0;
    }

    @Override
    public int deleteByIds(Integer[] intIds) {
        return commodityDao.deleteByIds(intIds);
    }

    @Override
    public Commodity findById(Integer id) {
        return commodityDao.findById(id);
    }

    @Override
    public boolean update(Commodity commodity) {
        return commodityDao.update(commodity)>0;
    }

    @Override
    public boolean findByCommodityId(Commodity commodity1) {
        return commodityDao.findByCommodityId(commodity1)>1;
    }
}
